package javabase.schoolwork.day6_19;

import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Scanner;

/**
 * @author fance
 * @date 2018/6/19 23:24
 */
public class URLTest {
    public static void main(String[] args) throws IOException {
        getPIcture();
    }

    private static void getPIcture() throws MalformedURLException, IOException, FileNotFoundException {
        URL url = new URL("http://jwc.jxau.edu.cn");
        InputStream inputStream = url.openStream();
        FileOutputStream fileOutputStream = new FileOutputStream("src/javabase/schoolwork/day6_19/test.txt",true);


        Scanner scanner = new Scanner(inputStream);
        scanner.useDelimiter("\n");

        while (scanner.hasNext()) {
            String s = scanner.next();
            if (s.endsWith(".img")) {
                fileOutputStream.write(s.getBytes());
            }
            System.out.println(s);
        }
    }


    public static void savePicture() throws IOException {
        FileReader fr = new FileReader("src/test/picture.txt");
        BufferedReader br=new BufferedReader(fr);
        String str=null;
        int i=1;

        while ((str = br.readLine().trim()) != null) {

        }
    }
    }
